<?php
/**附件管理控制器
 * @Author: 976123967@qq.com
 * @Date:   2014-09-21 21:40:06
 * @Last Modified by:   chen
 * @Last Modified time: 2014-10-28 22:34:09
 */
class AttachmentAction extends PublicAction{

	/**
	 * [__auto 初始化]
	 * @return [type] [description]
	 */
	public function _initialize()
	{
		parent::_initialize();
		$this->model = D('Upload');
	}

	/**
	 * [index 读取所有的附件]
	 * @return [type] [description]
	 */
	public function index()
	{

		$db = D('UploadView');
		$data = $db->get_upload_all();
		if($data)
		{
			$this->assign('page',$data['page']);
			unset($data['page']);
		}
		$this->assign('data',$data);
		$this->display();
	}

	/** 
	 * [del 删除]
	 * @return [type] [description]
	 */
	public function del()
	{
		$id = I('get.id',null,'intval');
		if(!$this->model->del_upload($id)) $this->error($this->model->getError());
		$this->success('删除成功',U('Attachment/index'));
	}


	/**
	 * [update_del 批量删除]
	 * @return [type] [description]
	 */
	public function update_del()
	{
		if(!$this->model->del_all()) $this->error($this->model->getError());
		$this->success('删除成功',U('Attachment/index'));
	}


}